using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Media.Animation;
namespace Microsoft.Expression.Interactivity.Core
{
	public class ExtendedVisualStateManager : VisualStateManager
	{
		internal class WrapperCanvas : Canvas
		{
			internal static readonly DependencyProperty SimulationProgressProperty = DependencyProperty.Register("SimulationProgress", typeof(double), typeof(ExtendedVisualStateManager.WrapperCanvas), new PropertyMetadata(0.0, new PropertyChangedCallback(ExtendedVisualStateManager.WrapperCanvas.SimulationProgressChanged)));
			public Rect OldRect
			{
				get;
				set;
			}
			public Rect NewRect
			{
				get;
				set;
			}
			public Dictionary<DependencyProperty, object> LocalValueCache
			{
				get;
				set;
			}
			public Visibility DestinationVisibilityCache
			{
				get;
				set;
			}
			public double SimulationProgress
			{
				get
				{
					return (double)base.GetValue(ExtendedVisualStateManager.WrapperCanvas.SimulationProgressProperty);
				}
				set
				{
					base.SetValue(ExtendedVisualStateManager.WrapperCanvas.SimulationProgressProperty, value);
				}
			}
			private static void SimulationProgressChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
			{
				ExtendedVisualStateManager.WrapperCanvas wrapperCanvas = d as ExtendedVisualStateManager.WrapperCanvas;
				double num = (double)e.get_NewValue();
				if (wrapperCanvas != null && wrapperCanvas.get_Children().get_Count() > 0)
				{
					FrameworkElement frameworkElement = wrapperCanvas.get_Children().get_Item(0) as FrameworkElement;
					frameworkElement.set_Width(Math.Max(0.0, wrapperCanvas.OldRect.get_Width() * num + wrapperCanvas.NewRect.get_Width() * (1.0 - num)));
					frameworkElement.set_Height(Math.Max(0.0, wrapperCanvas.OldRect.get_Height() * num + wrapperCanvas.NewRect.get_Height() * (1.0 - num)));
					Canvas.SetLeft(frameworkElement, num * (wrapperCanvas.OldRect.get_Left() - wrapperCanvas.NewRect.get_Left()));
					Canvas.SetTop(frameworkElement, num * (wrapperCanvas.OldRect.get_Top() - wrapperCanvas.NewRect.get_Top()));
				}
			}
		}
		internal class OriginalLayoutValueRecord
		{
			public FrameworkElement Element
			{
				get;
				set;
			}
			public DependencyProperty Property
			{
				get;
				set;
			}
			public object Value
			{
				get;
				set;
			}
		}
		public static readonly DependencyProperty UseFluidLayoutProperty = DependencyProperty.RegisterAttached("UseFluidLayout", typeof(bool), typeof(ExtendedVisualStateManager), new PropertyMetadata(false));
		public static readonly DependencyProperty RuntimeVisibilityPropertyProperty = DependencyProperty.RegisterAttached("RuntimeVisibilityProperty", typeof(DependencyProperty), typeof(ExtendedVisualStateManager), new PropertyMetadata(null));
		internal static readonly DependencyProperty OriginalLayoutValuesProperty = DependencyProperty.RegisterAttached("OriginalLayoutValues", typeof(List<ExtendedVisualStateManager.OriginalLayoutValueRecord>), typeof(ExtendedVisualStateManager), new PropertyMetadata(null));
		internal static readonly DependencyProperty LayoutStoryboardProperty = DependencyProperty.RegisterAttached("LayoutStoryboard", typeof(Storyboard), typeof(ExtendedVisualStateManager), new PropertyMetadata(null));
		internal static readonly DependencyProperty CurrentStateProperty = DependencyProperty.RegisterAttached("CurrentState", typeof(VisualState), typeof(ExtendedVisualStateManager), new PropertyMetadata(null));
		private static List<FrameworkElement> MovingElements;
		private static Storyboard LayoutTransitionStoryboard;
		private static List<DependencyProperty> LayoutProperties;
		private static List<DependencyProperty> ChildAffectingLayoutProperties;
		private static DependencyProperty RuntimeVisibility;
		private static Dictionary<string, DependencyProperty> PathToPropertyMap;
		public static bool IsRunningFluidLayoutTransition
		{
			get
			{
				return ExtendedVisualStateManager.LayoutTransitionStoryboard != null;
			}
		}
		public static bool GoToElementState(FrameworkElement root, string stateName, bool useTransitions)
		{
			ExtendedVisualStateManager extendedVisualStateManager = VisualStateManager.GetCustomVisualStateManager(root) as ExtendedVisualStateManager;
			return extendedVisualStateManager != null && extendedVisualStateManager.GoToStateInternal(root, stateName, useTransitions);
		}
		private bool GoToStateInternal(FrameworkElement stateGroupsRoot, string stateName, bool useTransitions)
		{
			VisualStateGroup visualStateGroup;
			VisualState visualState;
			return ExtendedVisualStateManager.TryGetState(stateGroupsRoot, stateName, out visualStateGroup, out visualState) && this.GoToStateCore(null, stateGroupsRoot, stateName, visualStateGroup, visualState, useTransitions);
		}
		private static bool TryGetState(FrameworkElement element, string stateName, out VisualStateGroup group, out VisualState state)
		{
			group = null;
			state = null;
			IList visualStateGroups = VisualStateManager.GetVisualStateGroups(element);
			IEnumerator enumerator = visualStateGroups.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					VisualStateGroup visualStateGroup = (VisualStateGroup)enumerator.get_Current();
					IEnumerator enumerator2 = visualStateGroup.get_States().GetEnumerator();
					try
					{
						while (enumerator2.MoveNext())
						{
							VisualState visualState = (VisualState)enumerator2.get_Current();
							if (visualState.get_Name() == stateName)
							{
								group = visualStateGroup;
								state = visualState;
								return true;
							}
						}
					}
					finally
					{
						IDisposable disposable = enumerator2 as IDisposable;
						if (disposable != null)
						{
							disposable.Dispose();
						}
					}
				}
			}
			finally
			{
				IDisposable disposable2 = enumerator as IDisposable;
				if (disposable2 != null)
				{
					disposable2.Dispose();
				}
			}
			return false;
		}
		public static bool GetUseFluidLayout(DependencyObject obj)
		{
			return (bool)obj.GetValue(ExtendedVisualStateManager.UseFluidLayoutProperty);
		}
		public static void SetUseFluidLayout(DependencyObject obj, bool value)
		{
			obj.SetValue(ExtendedVisualStateManager.UseFluidLayoutProperty, value);
		}
		public static DependencyProperty GetRuntimeVisibilityProperty(DependencyObject obj)
		{
			return (DependencyProperty)obj.GetValue(ExtendedVisualStateManager.RuntimeVisibilityPropertyProperty);
		}
		public static void SetRuntimeVisibilityProperty(DependencyObject obj, DependencyProperty value)
		{
			obj.SetValue(ExtendedVisualStateManager.RuntimeVisibilityPropertyProperty, value);
		}
		internal static List<ExtendedVisualStateManager.OriginalLayoutValueRecord> GetOriginalLayoutValues(DependencyObject obj)
		{
			return (List<ExtendedVisualStateManager.OriginalLayoutValueRecord>)obj.GetValue(ExtendedVisualStateManager.OriginalLayoutValuesProperty);
		}
		internal static void SetOriginalLayoutValues(DependencyObject obj, List<ExtendedVisualStateManager.OriginalLayoutValueRecord> value)
		{
			obj.SetValue(ExtendedVisualStateManager.OriginalLayoutValuesProperty, value);
		}
		internal static Storyboard GetLayoutStoryboard(DependencyObject obj)
		{
			return (Storyboard)obj.GetValue(ExtendedVisualStateManager.LayoutStoryboardProperty);
		}
		internal static void SetLayoutStoryboard(DependencyObject obj, Storyboard value)
		{
			obj.SetValue(ExtendedVisualStateManager.LayoutStoryboardProperty, value);
		}
		internal static VisualState GetCurrentState(DependencyObject obj)
		{
			return (VisualState)obj.GetValue(ExtendedVisualStateManager.CurrentStateProperty);
		}
		internal static void SetCurrentState(DependencyObject obj, VisualState value)
		{
			obj.SetValue(ExtendedVisualStateManager.CurrentStateProperty, value);
		}
		private static bool IsVisibilityProperty(DependencyProperty property)
		{
			if (ExtendedVisualStateManager.RuntimeVisibility != null)
			{
				if (property == ExtendedVisualStateManager.RuntimeVisibility)
				{
					return true;
				}
			}
			return property == UIElement.VisibilityProperty;
		}
		private static DependencyProperty LayoutPropertyFromTimeline(Timeline timeline, bool forceRuntimeProperty)
		{
			PropertyPath targetProperty = Storyboard.GetTargetProperty(timeline);
			DependencyProperty runtimeVisibilityProperty = ExtendedVisualStateManager.GetRuntimeVisibilityProperty(timeline);
			if (runtimeVisibilityProperty != null)
			{
				if (ExtendedVisualStateManager.RuntimeVisibility == null)
				{
					ExtendedVisualStateManager.LayoutProperties.Add(runtimeVisibilityProperty);
					ExtendedVisualStateManager.RuntimeVisibility = runtimeVisibilityProperty;
				}
				if (forceRuntimeProperty)
				{
					return runtimeVisibilityProperty;
				}
				return UIElement.VisibilityProperty;
			}
			else
			{
				DependencyProperty dependencyProperty;
				if (targetProperty != null && ExtendedVisualStateManager.PathToPropertyMap.TryGetValue(targetProperty.get_Path(), ref dependencyProperty) && ExtendedVisualStateManager.LayoutProperties.Contains(dependencyProperty))
				{
					return dependencyProperty;
				}
				return null;
			}
		}
		protected override bool GoToStateCore(Control control, FrameworkElement templateRoot, string stateName, VisualStateGroup group, VisualState state, bool useTransitions)
		{
			if (control == null)
			{
				control = new ContentControl();
			}
			if (group == null || state == null)
			{
				return false;
			}
			if (!ExtendedVisualStateManager.GetUseFluidLayout(group))
			{
				return base.GoToStateCore(control, templateRoot, stateName, group, state, useTransitions);
			}
			VisualState currentState = ExtendedVisualStateManager.GetCurrentState(group);
			if (currentState == state)
			{
				if (!useTransitions && ExtendedVisualStateManager.LayoutTransitionStoryboard != null)
				{
					ExtendedVisualStateManager.StopAnimations();
				}
				return true;
			}
			ExtendedVisualStateManager.SetCurrentState(group, state);
			Storyboard storyboard = ExtendedVisualStateManager.ExtractLayoutStoryboard(state);
			List<ExtendedVisualStateManager.OriginalLayoutValueRecord> list = ExtendedVisualStateManager.GetOriginalLayoutValues(group);
			if (list == null)
			{
				list = new List<ExtendedVisualStateManager.OriginalLayoutValueRecord>();
				ExtendedVisualStateManager.SetOriginalLayoutValues(group, list);
			}
			if (!useTransitions)
			{
				if (ExtendedVisualStateManager.LayoutTransitionStoryboard != null)
				{
					ExtendedVisualStateManager.StopAnimations();
				}
				base.GoToStateCore(control, templateRoot, stateName, group, state, useTransitions);
				ExtendedVisualStateManager.SetLayoutStoryboardProperties(control, templateRoot, storyboard, list);
				return true;
			}
			if (storyboard.get_Children().get_Count() == 0 && list.get_Count() == 0)
			{
				return base.GoToStateCore(control, templateRoot, stateName, group, state, useTransitions);
			}
			templateRoot.UpdateLayout();
			List<FrameworkElement> list2 = ExtendedVisualStateManager.FindTargetElements(control, templateRoot, storyboard, list, ExtendedVisualStateManager.MovingElements);
			Dictionary<FrameworkElement, Rect> rectsOfTargets = ExtendedVisualStateManager.GetRectsOfTargets(list2, ExtendedVisualStateManager.MovingElements);
			Dictionary<FrameworkElement, double> oldOpacities = ExtendedVisualStateManager.GetOldOpacities(control, templateRoot, storyboard, list, ExtendedVisualStateManager.MovingElements);
			if (ExtendedVisualStateManager.LayoutTransitionStoryboard != null)
			{
				templateRoot.remove_LayoutUpdated(new EventHandler(ExtendedVisualStateManager.control_LayoutUpdated));
				ExtendedVisualStateManager.StopAnimations();
				templateRoot.UpdateLayout();
			}
			base.GoToStateCore(control, templateRoot, stateName, group, state, useTransitions);
			ExtendedVisualStateManager.SetLayoutStoryboardProperties(control, templateRoot, storyboard, list);
			templateRoot.UpdateLayout();
			Dictionary<FrameworkElement, Rect> rectsOfTargets2 = ExtendedVisualStateManager.GetRectsOfTargets(list2, null);
			ExtendedVisualStateManager.MovingElements = new List<FrameworkElement>();
			using (List<FrameworkElement>.Enumerator enumerator = list2.GetEnumerator())
			{
				while (enumerator.MoveNext())
				{
					FrameworkElement current = enumerator.get_Current();
					if (rectsOfTargets.get_Item(current) != rectsOfTargets2.get_Item(current))
					{
						ExtendedVisualStateManager.MovingElements.Add(current);
					}
				}
			}
			using (Dictionary<FrameworkElement, double>.KeyCollection.Enumerator enumerator2 = oldOpacities.get_Keys().GetEnumerator())
			{
				while (enumerator2.MoveNext())
				{
					FrameworkElement current2 = enumerator2.get_Current();
					if (!ExtendedVisualStateManager.MovingElements.Contains(current2))
					{
						ExtendedVisualStateManager.MovingElements.Add(current2);
					}
				}
			}
			ExtendedVisualStateManager.WrapMovingElementsInCanvases(ExtendedVisualStateManager.MovingElements, rectsOfTargets, rectsOfTargets2);
			VisualTransition transition = ExtendedVisualStateManager.FindTransition(group, currentState, state);
			templateRoot.add_LayoutUpdated(new EventHandler(ExtendedVisualStateManager.control_LayoutUpdated));
			ExtendedVisualStateManager.LayoutTransitionStoryboard = ExtendedVisualStateManager.CreateLayoutTransitionStoryboard(transition, ExtendedVisualStateManager.MovingElements, oldOpacities);
			ExtendedVisualStateManager.LayoutTransitionStoryboard.add_Completed(delegate(object sender, EventArgs e)
			{
				templateRoot.remove_LayoutUpdated(new EventHandler(ExtendedVisualStateManager.control_LayoutUpdated));
				ExtendedVisualStateManager.StopAnimations();
			});
			ExtendedVisualStateManager.LayoutTransitionStoryboard.Begin();
			return true;
		}
		private static void control_LayoutUpdated(object sender, EventArgs e)
		{
			if (ExtendedVisualStateManager.LayoutTransitionStoryboard != null)
			{
				using (List<FrameworkElement>.Enumerator enumerator = ExtendedVisualStateManager.MovingElements.GetEnumerator())
				{
					while (enumerator.MoveNext())
					{
						FrameworkElement current = enumerator.get_Current();
						ExtendedVisualStateManager.WrapperCanvas wrapperCanvas = current.get_Parent() as ExtendedVisualStateManager.WrapperCanvas;
						if (wrapperCanvas != null)
						{
							Rect layoutRect = ExtendedVisualStateManager.GetLayoutRect(wrapperCanvas);
							Rect newRect = wrapperCanvas.NewRect;
							TranslateTransform translateTransform = wrapperCanvas.get_RenderTransform() as TranslateTransform;
							double num = (translateTransform == null) ? 0.0 : translateTransform.get_X();
							double num2 = (translateTransform == null) ? 0.0 : translateTransform.get_Y();
							double num3 = newRect.get_Left() - layoutRect.get_Left();
							double num4 = newRect.get_Top() - layoutRect.get_Top();
							if (num != num3 || num2 != num4)
							{
								if (translateTransform == null)
								{
									translateTransform = new TranslateTransform();
									wrapperCanvas.set_RenderTransform(translateTransform);
								}
								translateTransform.set_X(num3);
								translateTransform.set_Y(num4);
							}
						}
					}
				}
			}
		}
		private static void StopAnimations()
		{
			if (ExtendedVisualStateManager.LayoutTransitionStoryboard != null)
			{
				ExtendedVisualStateManager.LayoutTransitionStoryboard.Stop();
				ExtendedVisualStateManager.LayoutTransitionStoryboard = null;
			}
			if (ExtendedVisualStateManager.MovingElements != null)
			{
				ExtendedVisualStateManager.UnwrapMovingElementsFromCanvases(ExtendedVisualStateManager.MovingElements);
				ExtendedVisualStateManager.MovingElements = null;
			}
		}
		private static VisualTransition FindTransition(VisualStateGroup group, VisualState previousState, VisualState state)
		{
			string text = (previousState != null) ? previousState.get_Name() : string.Empty;
			string text2 = (state != null) ? state.get_Name() : string.Empty;
			int num = -1;
			VisualTransition result = null;
			if (group.get_Transitions() != null)
			{
				IEnumerator enumerator = group.get_Transitions().GetEnumerator();
				try
				{
					while (enumerator.MoveNext())
					{
						VisualTransition visualTransition = (VisualTransition)enumerator.get_Current();
						int num2 = 0;
						if (visualTransition.get_From() == text)
						{
							num2++;
						}
						else
						{
							if (!string.IsNullOrEmpty(visualTransition.get_From()))
							{
								continue;
							}
						}
						if (visualTransition.get_To() == text2)
						{
							num2 += 2;
						}
						else
						{
							if (!string.IsNullOrEmpty(visualTransition.get_To()))
							{
								continue;
							}
						}
						if (num2 > num)
						{
							num = num2;
							result = visualTransition;
						}
					}
				}
				finally
				{
					IDisposable disposable = enumerator as IDisposable;
					if (disposable != null)
					{
						disposable.Dispose();
					}
				}
			}
			return result;
		}
		private static Storyboard ExtractLayoutStoryboard(VisualState state)
		{
			Storyboard storyboard = null;
			if (state.get_Storyboard() != null)
			{
				storyboard = ExtendedVisualStateManager.GetLayoutStoryboard(state.get_Storyboard());
				if (storyboard == null)
				{
					storyboard = new Storyboard();
					for (int i = state.get_Storyboard().get_Children().get_Count() - 1; i >= 0; i--)
					{
						Timeline timeline = state.get_Storyboard().get_Children().get_Item(i);
						if (ExtendedVisualStateManager.LayoutPropertyFromTimeline(timeline, false) != null)
						{
							state.get_Storyboard().get_Children().RemoveAt(i);
							storyboard.get_Children().Add(timeline);
						}
					}
					ExtendedVisualStateManager.SetLayoutStoryboard(state.get_Storyboard(), storyboard);
				}
			}
			if (storyboard == null)
			{
				return new Storyboard();
			}
			return storyboard;
		}
		private static List<FrameworkElement> FindTargetElements(Control control, FrameworkElement templateRoot, Storyboard layoutStoryboard, List<ExtendedVisualStateManager.OriginalLayoutValueRecord> originalValueRecords, List<FrameworkElement> movingElements)
		{
			List<FrameworkElement> list = new List<FrameworkElement>();
			if (movingElements != null)
			{
				list.AddRange(movingElements);
			}
			using (IEnumerator<Timeline> enumerator = layoutStoryboard.get_Children().GetEnumerator())
			{
				while (enumerator.MoveNext())
				{
					Timeline current = enumerator.get_Current();
					FrameworkElement frameworkElement = (FrameworkElement)ExtendedVisualStateManager.GetTimelineTarget(control, templateRoot, current);
					if (frameworkElement != null)
					{
						if (!list.Contains(frameworkElement))
						{
							list.Add(frameworkElement);
						}
						if (ExtendedVisualStateManager.ChildAffectingLayoutProperties.Contains(ExtendedVisualStateManager.LayoutPropertyFromTimeline(current, false)))
						{
							Panel panel = frameworkElement as Panel;
							if (panel != null)
							{
								using (IEnumerator<UIElement> enumerator2 = panel.get_Children().GetEnumerator())
								{
									while (enumerator2.MoveNext())
									{
										FrameworkElement frameworkElement2 = (FrameworkElement)enumerator2.get_Current();
										if (!list.Contains(frameworkElement2) && !(frameworkElement2 is ExtendedVisualStateManager.WrapperCanvas))
										{
											list.Add(frameworkElement2);
										}
									}
								}
							}
						}
					}
				}
			}
			using (List<ExtendedVisualStateManager.OriginalLayoutValueRecord>.Enumerator enumerator3 = originalValueRecords.GetEnumerator())
			{
				while (enumerator3.MoveNext())
				{
					ExtendedVisualStateManager.OriginalLayoutValueRecord current2 = enumerator3.get_Current();
					if (!list.Contains(current2.Element))
					{
						list.Add(current2.Element);
					}
					if (ExtendedVisualStateManager.ChildAffectingLayoutProperties.Contains(current2.Property))
					{
						Panel panel2 = current2.Element as Panel;
						if (panel2 != null)
						{
							using (IEnumerator<UIElement> enumerator4 = panel2.get_Children().GetEnumerator())
							{
								while (enumerator4.MoveNext())
								{
									FrameworkElement frameworkElement3 = (FrameworkElement)enumerator4.get_Current();
									if (!list.Contains(frameworkElement3) && !(frameworkElement3 is ExtendedVisualStateManager.WrapperCanvas))
									{
										list.Add(frameworkElement3);
									}
								}
							}
						}
					}
				}
			}
			for (int i = 0; i < list.get_Count(); i++)
			{
				FrameworkElement frameworkElement4 = list.get_Item(i);
				FrameworkElement frameworkElement5 = VisualTreeHelper.GetParent(frameworkElement4) as FrameworkElement;
				if (movingElements != null && movingElements.Contains(frameworkElement4) && frameworkElement5 is ExtendedVisualStateManager.WrapperCanvas)
				{
					frameworkElement5 = (VisualTreeHelper.GetParent(frameworkElement5) as FrameworkElement);
				}
				if (frameworkElement5 != null)
				{
					if (!list.Contains(frameworkElement5))
					{
						list.Add(frameworkElement5);
					}
					for (int j = 0; j < VisualTreeHelper.GetChildrenCount(frameworkElement5); j++)
					{
						FrameworkElement frameworkElement6 = VisualTreeHelper.GetChild(frameworkElement5, j) as FrameworkElement;
						if (frameworkElement6 != null && !list.Contains(frameworkElement6) && !(frameworkElement6 is ExtendedVisualStateManager.WrapperCanvas))
						{
							list.Add(frameworkElement6);
						}
					}
				}
			}
			return list;
		}
		private static object GetTimelineTarget(Control control, FrameworkElement templateRoot, Timeline timeline)
		{
			string targetName = Storyboard.GetTargetName(timeline);
			if (string.IsNullOrEmpty(targetName))
			{
				return null;
			}
			if (control is UserControl)
			{
				return control.FindName(targetName);
			}
			return templateRoot.FindName(targetName);
		}
		private static Dictionary<FrameworkElement, Rect> GetRectsOfTargets(List<FrameworkElement> targets, List<FrameworkElement> movingElements)
		{
			Dictionary<FrameworkElement, Rect> dictionary = new Dictionary<FrameworkElement, Rect>();
			using (List<FrameworkElement>.Enumerator enumerator = targets.GetEnumerator())
			{
				while (enumerator.MoveNext())
				{
					FrameworkElement current = enumerator.get_Current();
					Rect layoutRect;
					if (movingElements != null && movingElements.Contains(current) && current.get_Parent() is ExtendedVisualStateManager.WrapperCanvas)
					{
						ExtendedVisualStateManager.WrapperCanvas wrapperCanvas = current.get_Parent() as ExtendedVisualStateManager.WrapperCanvas;
						layoutRect = ExtendedVisualStateManager.GetLayoutRect(wrapperCanvas);
						TranslateTransform translateTransform = wrapperCanvas.get_RenderTransform() as TranslateTransform;
						double left = Canvas.GetLeft(current);
						double top = Canvas.GetTop(current);
						layoutRect = new Rect(layoutRect.get_Left() + (double.IsNaN(left) ? 0.0 : left) + ((translateTransform == null) ? 0.0 : translateTransform.get_X()), layoutRect.get_Top() + (double.IsNaN(top) ? 0.0 : top) + ((translateTransform == null) ? 0.0 : translateTransform.get_Y()), current.get_ActualWidth(), current.get_ActualHeight());
					}
					else
					{
						layoutRect = ExtendedVisualStateManager.GetLayoutRect(current);
					}
					dictionary.Add(current, layoutRect);
				}
			}
			return dictionary;
		}
		internal static Rect GetLayoutRect(FrameworkElement element)
		{
			double num = element.get_ActualWidth();
			double num2 = element.get_ActualHeight();
			if (element is Image || element is MediaElement)
			{
				if (element.get_Parent().GetType() == typeof(Canvas))
				{
					num = (double.IsNaN(element.get_Width()) ? num : element.get_Width());
					num2 = (double.IsNaN(element.get_Height()) ? num2 : element.get_Height());
				}
				else
				{
					num = element.get_RenderSize().get_Width();
					num2 = element.get_RenderSize().get_Height();
				}
			}
			num = ((element.get_Visibility() == 1) ? 0.0 : num);
			num2 = ((element.get_Visibility() == 1) ? 0.0 : num2);
			Thickness margin = element.get_Margin();
			Rect layoutSlot = LayoutInformation.GetLayoutSlot(element);
			if (element.get_Parent() is Canvas)
			{
				layoutSlot = new Rect(Canvas.GetLeft(element), Canvas.GetTop(element), num, num2);
			}
			double num3 = 0.0;
			double num4 = 0.0;
			switch (element.get_HorizontalAlignment())
			{
			case 0:
				num3 = layoutSlot.get_Left() + margin.get_Left();
				break;
			case 1:
				num3 = (layoutSlot.get_Left() + margin.get_Left() + layoutSlot.get_Right() - margin.get_Right()) / 2.0 - num / 2.0;
				break;
			case 2:
				num3 = layoutSlot.get_Right() - margin.get_Right() - num;
				break;
			case 3:
				num3 = Math.Max(layoutSlot.get_Left() + margin.get_Left(), (layoutSlot.get_Left() + margin.get_Left() + layoutSlot.get_Right() - margin.get_Right()) / 2.0 - num / 2.0);
				break;
			}
			switch (element.get_VerticalAlignment())
			{
			case 0:
				num4 = layoutSlot.get_Top() + margin.get_Top();
				break;
			case 1:
				num4 = (layoutSlot.get_Top() + margin.get_Top() + layoutSlot.get_Bottom() - margin.get_Bottom()) / 2.0 - num2 / 2.0;
				break;
			case 2:
				num4 = layoutSlot.get_Bottom() - margin.get_Bottom() - num2;
				break;
			case 3:
				num4 = Math.Max(layoutSlot.get_Top() + margin.get_Top(), (layoutSlot.get_Top() + margin.get_Top() + layoutSlot.get_Bottom() - margin.get_Bottom()) / 2.0 - num2 / 2.0);
				break;
			}
			return new Rect(num3, num4, num, num2);
		}
		private static Dictionary<FrameworkElement, double> GetOldOpacities(Control control, FrameworkElement templateRoot, Storyboard layoutStoryboard, List<ExtendedVisualStateManager.OriginalLayoutValueRecord> originalValueRecords, List<FrameworkElement> movingElements)
		{
			Dictionary<FrameworkElement, double> dictionary = new Dictionary<FrameworkElement, double>();
			if (movingElements != null)
			{
				using (List<FrameworkElement>.Enumerator enumerator = movingElements.GetEnumerator())
				{
					while (enumerator.MoveNext())
					{
						FrameworkElement current = enumerator.get_Current();
						ExtendedVisualStateManager.WrapperCanvas wrapperCanvas = current.get_Parent() as ExtendedVisualStateManager.WrapperCanvas;
						if (wrapperCanvas != null)
						{
							dictionary.Add(current, wrapperCanvas.get_Opacity());
						}
					}
				}
			}
			for (int i = originalValueRecords.get_Count() - 1; i >= 0; i--)
			{
				ExtendedVisualStateManager.OriginalLayoutValueRecord originalLayoutValueRecord = originalValueRecords.get_Item(i);
				double num;
				if (ExtendedVisualStateManager.IsVisibilityProperty(originalLayoutValueRecord.Property) && !dictionary.TryGetValue(originalLayoutValueRecord.Element, ref num))
				{
					num = (((Visibility)originalLayoutValueRecord.Element.GetValue(originalLayoutValueRecord.Property) == null) ? 1.0 : 0.0);
					dictionary.Add(originalLayoutValueRecord.Element, num);
				}
			}
			using (IEnumerator<Timeline> enumerator2 = layoutStoryboard.get_Children().GetEnumerator())
			{
				while (enumerator2.MoveNext())
				{
					Timeline current2 = enumerator2.get_Current();
					FrameworkElement frameworkElement = (FrameworkElement)ExtendedVisualStateManager.GetTimelineTarget(control, templateRoot, current2);
					DependencyProperty dependencyProperty = ExtendedVisualStateManager.LayoutPropertyFromTimeline(current2, true);
					double num2;
					if (frameworkElement != null && ExtendedVisualStateManager.IsVisibilityProperty(dependencyProperty) && !dictionary.TryGetValue(frameworkElement, ref num2))
					{
						num2 = (((Visibility)frameworkElement.GetValue(dependencyProperty) == null) ? 1.0 : 0.0);
						dictionary.Add(frameworkElement, num2);
					}
				}
			}
			return dictionary;
		}
		private static void SetLayoutStoryboardProperties(Control control, FrameworkElement templateRoot, Storyboard layoutStoryboard, List<ExtendedVisualStateManager.OriginalLayoutValueRecord> originalValueRecords)
		{
			using (List<ExtendedVisualStateManager.OriginalLayoutValueRecord>.Enumerator enumerator = originalValueRecords.GetEnumerator())
			{
				while (enumerator.MoveNext())
				{
					ExtendedVisualStateManager.OriginalLayoutValueRecord current = enumerator.get_Current();
					ExtendedVisualStateManager.ReplaceCachedLocalValueHelper(current.Element, current.Property, current.Value);
				}
			}
			originalValueRecords.Clear();
			using (IEnumerator<Timeline> enumerator2 = layoutStoryboard.get_Children().GetEnumerator())
			{
				while (enumerator2.MoveNext())
				{
					Timeline current2 = enumerator2.get_Current();
					FrameworkElement frameworkElement = (FrameworkElement)ExtendedVisualStateManager.GetTimelineTarget(control, templateRoot, current2);
					DependencyProperty dependencyProperty = ExtendedVisualStateManager.LayoutPropertyFromTimeline(current2, true);
					if (frameworkElement != null && dependencyProperty != null)
					{
						object obj = null;
						bool flag = false;
						ObjectAnimationUsingKeyFrames objectAnimationUsingKeyFrames = current2 as ObjectAnimationUsingKeyFrames;
						if (objectAnimationUsingKeyFrames != null)
						{
							flag = true;
							obj = objectAnimationUsingKeyFrames.get_KeyFrames().get_Item(0).get_Value();
						}
						else
						{
							DoubleAnimationUsingKeyFrames doubleAnimationUsingKeyFrames = current2 as DoubleAnimationUsingKeyFrames;
							if (doubleAnimationUsingKeyFrames != null)
							{
								flag = true;
								obj = doubleAnimationUsingKeyFrames.get_KeyFrames().get_Item(0).get_Value();
							}
							else
							{
								DoubleAnimation doubleAnimation = current2 as DoubleAnimation;
								if (doubleAnimation != null)
								{
									flag = true;
									obj = doubleAnimation.get_To();
								}
							}
						}
						if (ExtendedVisualStateManager.IsVisibilityProperty(dependencyProperty) && !(obj is Visibility))
						{
							obj = Enum.Parse(typeof(Visibility), obj.ToString(), true);
						}
						else
						{
							if (dependencyProperty == FrameworkElement.HorizontalAlignmentProperty && !(obj is HorizontalAlignment))
							{
								obj = Enum.Parse(typeof(HorizontalAlignment), obj.ToString(), true);
							}
							else
							{
								if (dependencyProperty == FrameworkElement.VerticalAlignmentProperty && !(obj is VerticalAlignment))
								{
									obj = Enum.Parse(typeof(VerticalAlignment), obj.ToString(), true);
								}
								else
								{
									if (dependencyProperty == StackPanel.OrientationProperty && !(obj is Orientation))
									{
										obj = Enum.Parse(typeof(Orientation), obj.ToString(), true);
									}
									else
									{
										if (dependencyProperty == FrameworkElement.MarginProperty && !(obj is Thickness))
										{
											string[] array = obj.ToString().Split(new char[]
											{
												','
											});
											double num = double.Parse(array[0], CultureInfo.get_InvariantCulture());
											double num2 = (array.Length < 1) ? num : double.Parse(array[1], CultureInfo.get_InvariantCulture());
											double num3 = (array.Length < 2) ? num : double.Parse(array[2], CultureInfo.get_InvariantCulture());
											double num4 = (array.Length < 3) ? num2 : double.Parse(array[3], CultureInfo.get_InvariantCulture());
											obj = new Thickness(num, num2, num3, num4);
										}
									}
								}
							}
						}
						if ((dependencyProperty == FrameworkElement.WidthProperty || dependencyProperty == FrameworkElement.HeightProperty) && (double)obj == -1.0)
						{
							obj = double.NaN;
						}
						if (flag)
						{
							originalValueRecords.Add(new ExtendedVisualStateManager.OriginalLayoutValueRecord
							{
								Element = frameworkElement,
								Property = dependencyProperty,
								Value = ExtendedVisualStateManager.CacheLocalValueHelper(frameworkElement, dependencyProperty)
							});
							frameworkElement.SetValue(dependencyProperty, obj);
						}
					}
				}
			}
		}
		private static void WrapMovingElementsInCanvases(List<FrameworkElement> movingElements, Dictionary<FrameworkElement, Rect> oldRects, Dictionary<FrameworkElement, Rect> newRects)
		{
			using (List<FrameworkElement>.Enumerator enumerator = movingElements.GetEnumerator())
			{
				while (enumerator.MoveNext())
				{
					FrameworkElement current = enumerator.get_Current();
					FrameworkElement frameworkElement = VisualTreeHelper.GetParent(current) as FrameworkElement;
					ExtendedVisualStateManager.WrapperCanvas wrapperCanvas = new ExtendedVisualStateManager.WrapperCanvas();
					wrapperCanvas.OldRect = oldRects.get_Item(current);
					wrapperCanvas.NewRect = newRects.get_Item(current);
					using (List<DependencyProperty>.Enumerator enumerator2 = ExtendedVisualStateManager.LayoutProperties.GetEnumerator())
					{
						while (enumerator2.MoveNext())
						{
							DependencyProperty current2 = enumerator2.get_Current();
							if (!ExtendedVisualStateManager.ChildAffectingLayoutProperties.Contains(current2))
							{
								object obj = ExtendedVisualStateManager.CacheLocalValueHelper(current, current2);
								if (obj is TemplateBindingExpression)
								{
									return;
								}
							}
						}
					}
					bool flag = true;
					Panel panel = frameworkElement as Panel;
					if (panel != null && !panel.get_IsItemsHost())
					{
						int num = panel.get_Children().IndexOf(current);
						panel.get_Children().RemoveAt(num);
						panel.get_Children().Insert(num, wrapperCanvas);
					}
					else
					{
						Border border = frameworkElement as Border;
						if (border != null)
						{
							border.set_Child(wrapperCanvas);
						}
						else
						{
							flag = false;
						}
					}
					if (flag)
					{
						wrapperCanvas.get_Children().Add(current);
						ExtendedVisualStateManager.CopyLayoutProperties(current, wrapperCanvas, false);
					}
				}
			}
		}
		private static void UnwrapMovingElementsFromCanvases(List<FrameworkElement> movingElements)
		{
			using (List<FrameworkElement>.Enumerator enumerator = movingElements.GetEnumerator())
			{
				while (enumerator.MoveNext())
				{
					FrameworkElement current = enumerator.get_Current();
					ExtendedVisualStateManager.WrapperCanvas wrapperCanvas = current.get_Parent() as ExtendedVisualStateManager.WrapperCanvas;
					if (wrapperCanvas != null)
					{
						FrameworkElement frameworkElement = VisualTreeHelper.GetParent(wrapperCanvas) as FrameworkElement;
						wrapperCanvas.get_Children().Remove(current);
						Panel panel = frameworkElement as Panel;
						if (panel != null)
						{
							int num = panel.get_Children().IndexOf(wrapperCanvas);
							panel.get_Children().RemoveAt(num);
							panel.get_Children().Insert(num, current);
						}
						else
						{
							Border border = frameworkElement as Border;
							if (border != null)
							{
								border.set_Child(current);
							}
						}
						ExtendedVisualStateManager.CopyLayoutProperties(wrapperCanvas, current, true);
					}
				}
			}
		}
		private static void CopyLayoutProperties(FrameworkElement source, FrameworkElement target, bool restoring)
		{
			ExtendedVisualStateManager.WrapperCanvas wrapperCanvas = (restoring ? source : target) as ExtendedVisualStateManager.WrapperCanvas;
			if (wrapperCanvas.LocalValueCache == null)
			{
				wrapperCanvas.LocalValueCache = new Dictionary<DependencyProperty, object>();
			}
			using (List<DependencyProperty>.Enumerator enumerator = ExtendedVisualStateManager.LayoutProperties.GetEnumerator())
			{
				while (enumerator.MoveNext())
				{
					DependencyProperty current = enumerator.get_Current();
					if (!ExtendedVisualStateManager.ChildAffectingLayoutProperties.Contains(current))
					{
						if (restoring)
						{
							ExtendedVisualStateManager.ReplaceCachedLocalValueHelper(target, current, wrapperCanvas.LocalValueCache.get_Item(current));
						}
						else
						{
							object value = target.GetValue(current);
							object obj = ExtendedVisualStateManager.CacheLocalValueHelper(source, current);
							wrapperCanvas.LocalValueCache.set_Item(current, obj);
							if (obj is TemplateBindingExpression)
							{
								string text = null;
								using (Dictionary<string, DependencyProperty>.Enumerator enumerator2 = ExtendedVisualStateManager.PathToPropertyMap.GetEnumerator())
								{
									while (enumerator2.MoveNext())
									{
										KeyValuePair<string, DependencyProperty> current2 = enumerator2.get_Current();
										if (current2.get_Value() == current || (current == ExtendedVisualStateManager.RuntimeVisibility && current2.get_Value() == UIElement.VisibilityProperty))
										{
											text = current2.get_Key();
										}
									}
								}
								throw new ArgumentException(string.Format(CultureInfo.get_CurrentCulture(), ExceptionStringTable.ChangePropertyActionCannotSetValueExceptionMessage, new object[]
								{
									typeof(TemplateBindingExpression).get_Name(),
									text,
									((value == null) ? typeof(object) : value.GetType()).get_Name()
								}));
							}
							if (ExtendedVisualStateManager.IsVisibilityProperty(current))
							{
								wrapperCanvas.DestinationVisibilityCache = (Visibility)source.GetValue(current);
							}
							else
							{
								target.SetValue(current, source.GetValue(current));
							}
							source.SetValue(current, value);
						}
					}
				}
			}
		}
		private static Storyboard CreateLayoutTransitionStoryboard(VisualTransition transition, List<FrameworkElement> movingElements, Dictionary<FrameworkElement, double> oldOpacities)
		{
			Duration duration = (transition != null) ? transition.get_GeneratedDuration() : new Duration(TimeSpan.Zero);
			IEasingFunction easingFunction = (transition != null) ? transition.get_GeneratedEasingFunction() : null;
			Storyboard storyboard = new Storyboard();
			storyboard.set_Duration(duration);
			using (List<FrameworkElement>.Enumerator enumerator = movingElements.GetEnumerator())
			{
				while (enumerator.MoveNext())
				{
					FrameworkElement current = enumerator.get_Current();
					ExtendedVisualStateManager.WrapperCanvas wrapperCanvas = current.get_Parent() as ExtendedVisualStateManager.WrapperCanvas;
					if (wrapperCanvas != null)
					{
						DoubleAnimation doubleAnimation = new DoubleAnimation();
						doubleAnimation.set_From(new double?(1.0));
						doubleAnimation.set_To(new double?(0.0));
						doubleAnimation.set_Duration(duration);
						DoubleAnimation doubleAnimation2 = doubleAnimation;
						doubleAnimation2.set_EasingFunction(easingFunction);
						Storyboard.SetTarget(doubleAnimation2, wrapperCanvas);
						Storyboard.SetTargetProperty(doubleAnimation2, new PropertyPath(ExtendedVisualStateManager.WrapperCanvas.SimulationProgressProperty));
						storyboard.get_Children().Add(doubleAnimation2);
						wrapperCanvas.SimulationProgress = 1.0;
						Rect newRect = wrapperCanvas.NewRect;
						if (!ExtendedVisualStateManager.IsClose(wrapperCanvas.get_Width(), newRect.get_Width()))
						{
							DoubleAnimation doubleAnimation3 = new DoubleAnimation();
							doubleAnimation3.set_From(new double?(newRect.get_Width()));
							doubleAnimation3.set_To(new double?(newRect.get_Width()));
							doubleAnimation3.set_Duration(duration);
							DoubleAnimation doubleAnimation4 = doubleAnimation3;
							Storyboard.SetTarget(doubleAnimation4, wrapperCanvas);
							Storyboard.SetTargetProperty(doubleAnimation4, new PropertyPath(FrameworkElement.WidthProperty));
							storyboard.get_Children().Add(doubleAnimation4);
						}
						if (!ExtendedVisualStateManager.IsClose(wrapperCanvas.get_Height(), newRect.get_Height()))
						{
							DoubleAnimation doubleAnimation5 = new DoubleAnimation();
							doubleAnimation5.set_From(new double?(newRect.get_Height()));
							doubleAnimation5.set_To(new double?(newRect.get_Height()));
							doubleAnimation5.set_Duration(duration);
							DoubleAnimation doubleAnimation6 = doubleAnimation5;
							Storyboard.SetTarget(doubleAnimation6, wrapperCanvas);
							Storyboard.SetTargetProperty(doubleAnimation6, new PropertyPath(FrameworkElement.HeightProperty));
							storyboard.get_Children().Add(doubleAnimation6);
						}
						if (wrapperCanvas.DestinationVisibilityCache == 1)
						{
							Thickness margin = wrapperCanvas.get_Margin();
							if (!ExtendedVisualStateManager.IsClose(margin.get_Left(), 0.0) || !ExtendedVisualStateManager.IsClose(margin.get_Top(), 0.0) || !ExtendedVisualStateManager.IsClose(margin.get_Right(), 0.0) || !ExtendedVisualStateManager.IsClose(margin.get_Bottom(), 0.0))
							{
								ObjectAnimationUsingKeyFrames objectAnimationUsingKeyFrames = new ObjectAnimationUsingKeyFrames();
								objectAnimationUsingKeyFrames.set_Duration(duration);
								ObjectAnimationUsingKeyFrames objectAnimationUsingKeyFrames2 = objectAnimationUsingKeyFrames;
								DiscreteObjectKeyFrame discreteObjectKeyFrame = new DiscreteObjectKeyFrame();
								discreteObjectKeyFrame.set_KeyTime(TimeSpan.Zero);
								discreteObjectKeyFrame.set_Value(default(Thickness));
								DiscreteObjectKeyFrame discreteObjectKeyFrame2 = discreteObjectKeyFrame;
								objectAnimationUsingKeyFrames2.get_KeyFrames().Add(discreteObjectKeyFrame2);
								Storyboard.SetTarget(objectAnimationUsingKeyFrames2, wrapperCanvas);
								Storyboard.SetTargetProperty(objectAnimationUsingKeyFrames2, new PropertyPath(FrameworkElement.MarginProperty));
								storyboard.get_Children().Add(objectAnimationUsingKeyFrames2);
							}
							if (!ExtendedVisualStateManager.IsClose(wrapperCanvas.get_MinWidth(), 0.0))
							{
								DoubleAnimation doubleAnimation7 = new DoubleAnimation();
								doubleAnimation7.set_From(new double?(0.0));
								doubleAnimation7.set_To(new double?(0.0));
								doubleAnimation7.set_Duration(duration);
								DoubleAnimation doubleAnimation8 = doubleAnimation7;
								Storyboard.SetTarget(doubleAnimation8, wrapperCanvas);
								Storyboard.SetTargetProperty(doubleAnimation8, new PropertyPath(FrameworkElement.MinWidthProperty));
								storyboard.get_Children().Add(doubleAnimation8);
							}
							if (!ExtendedVisualStateManager.IsClose(wrapperCanvas.get_MinHeight(), 0.0))
							{
								DoubleAnimation doubleAnimation9 = new DoubleAnimation();
								doubleAnimation9.set_From(new double?(0.0));
								doubleAnimation9.set_To(new double?(0.0));
								doubleAnimation9.set_Duration(duration);
								DoubleAnimation doubleAnimation10 = doubleAnimation9;
								Storyboard.SetTarget(doubleAnimation10, wrapperCanvas);
								Storyboard.SetTargetProperty(doubleAnimation10, new PropertyPath(FrameworkElement.MinHeightProperty));
								storyboard.get_Children().Add(doubleAnimation10);
							}
						}
					}
				}
			}
			using (Dictionary<FrameworkElement, double>.KeyCollection.Enumerator enumerator2 = oldOpacities.get_Keys().GetEnumerator())
			{
				while (enumerator2.MoveNext())
				{
					FrameworkElement current2 = enumerator2.get_Current();
					ExtendedVisualStateManager.WrapperCanvas wrapperCanvas2 = current2.get_Parent() as ExtendedVisualStateManager.WrapperCanvas;
					if (wrapperCanvas2 != null)
					{
						double num = oldOpacities.get_Item(current2);
						double num2 = (wrapperCanvas2.DestinationVisibilityCache == null) ? 1.0 : 0.0;
						if (!ExtendedVisualStateManager.IsClose(num, 1.0) || !ExtendedVisualStateManager.IsClose(num2, 1.0))
						{
							DoubleAnimation doubleAnimation11 = new DoubleAnimation();
							doubleAnimation11.set_From(new double?(num));
							doubleAnimation11.set_To(new double?(num2));
							doubleAnimation11.set_Duration(duration);
							DoubleAnimation doubleAnimation12 = doubleAnimation11;
							doubleAnimation12.set_EasingFunction(easingFunction);
							Storyboard.SetTarget(doubleAnimation12, wrapperCanvas2);
							Storyboard.SetTargetProperty(doubleAnimation12, new PropertyPath(UIElement.OpacityProperty));
							storyboard.get_Children().Add(doubleAnimation12);
						}
					}
				}
			}
			return storyboard;
		}
		private static object CacheLocalValueHelper(DependencyObject dependencyObject, DependencyProperty property)
		{
			return dependencyObject.ReadLocalValue(property);
		}
		private static void ReplaceCachedLocalValueHelper(FrameworkElement element, DependencyProperty property, object value)
		{
			if (value == DependencyProperty.UnsetValue)
			{
				element.ClearValue(property);
				return;
			}
			BindingExpression bindingExpression = value as BindingExpression;
			if (bindingExpression != null)
			{
				element.SetBinding(property, bindingExpression.get_ParentBinding());
				return;
			}
			element.SetValue(property, value);
		}
		private static bool IsClose(double a, double b)
		{
			return Math.Abs(a - b) < 1E-07;
		}
		static ExtendedVisualStateManager()
		{
			// Note: this type is marked as 'beforefieldinit'.
			List<DependencyProperty> list = new List<DependencyProperty>();
			list.Add(Grid.ColumnProperty);
			list.Add(Grid.ColumnSpanProperty);
			list.Add(Grid.RowProperty);
			list.Add(Grid.RowSpanProperty);
			list.Add(Canvas.LeftProperty);
			list.Add(Canvas.TopProperty);
			list.Add(FrameworkElement.WidthProperty);
			list.Add(FrameworkElement.HeightProperty);
			list.Add(FrameworkElement.MinWidthProperty);
			list.Add(FrameworkElement.MinHeightProperty);
			list.Add(FrameworkElement.MaxWidthProperty);
			list.Add(FrameworkElement.MaxHeightProperty);
			list.Add(FrameworkElement.MarginProperty);
			list.Add(FrameworkElement.HorizontalAlignmentProperty);
			list.Add(FrameworkElement.VerticalAlignmentProperty);
			list.Add(UIElement.VisibilityProperty);
			list.Add(StackPanel.OrientationProperty);
			ExtendedVisualStateManager.LayoutProperties = list;
			List<DependencyProperty> list2 = new List<DependencyProperty>();
			list2.Add(StackPanel.OrientationProperty);
			ExtendedVisualStateManager.ChildAffectingLayoutProperties = list2;
			Dictionary<string, DependencyProperty> dictionary = new Dictionary<string, DependencyProperty>();
			dictionary.Add("(Grid.Column)", Grid.ColumnProperty);
			dictionary.Add("(Grid.ColumnSpan)", Grid.ColumnSpanProperty);
			dictionary.Add("(Grid.Row)", Grid.RowProperty);
			dictionary.Add("(Grid.RowSpan)", Grid.RowSpanProperty);
			dictionary.Add("(Canvas.Left)", Canvas.LeftProperty);
			dictionary.Add("(Canvas.Top)", Canvas.TopProperty);
			dictionary.Add("(FrameworkElement.Width)", FrameworkElement.WidthProperty);
			dictionary.Add("(FrameworkElement.Height)", FrameworkElement.HeightProperty);
			dictionary.Add("(FrameworkElement.MinWidth)", FrameworkElement.MinWidthProperty);
			dictionary.Add("(FrameworkElement.MinHeight)", FrameworkElement.MinHeightProperty);
			dictionary.Add("(FrameworkElement.MaxWidth)", FrameworkElement.MaxWidthProperty);
			dictionary.Add("(FrameworkElement.MaxHeight)", FrameworkElement.MaxHeightProperty);
			dictionary.Add("(FrameworkElement.Margin)", FrameworkElement.MarginProperty);
			dictionary.Add("(FrameworkElement.HorizontalAlignment)", FrameworkElement.HorizontalAlignmentProperty);
			dictionary.Add("(FrameworkElement.VerticalAlignment)", FrameworkElement.VerticalAlignmentProperty);
			dictionary.Add("(UIElement.Visibility)", UIElement.VisibilityProperty);
			dictionary.Add("(Control.Width)", FrameworkElement.WidthProperty);
			dictionary.Add("(Control.Height)", FrameworkElement.HeightProperty);
			dictionary.Add("(Control.MinWidth)", FrameworkElement.MinWidthProperty);
			dictionary.Add("(Control.MinHeight)", FrameworkElement.MinHeightProperty);
			dictionary.Add("(Control.MaxWidth)", FrameworkElement.MaxWidthProperty);
			dictionary.Add("(Control.MaxHeight)", FrameworkElement.MaxHeightProperty);
			dictionary.Add("(Control.Margin)", FrameworkElement.MarginProperty);
			dictionary.Add("(Control.HorizontalAlignment)", FrameworkElement.HorizontalAlignmentProperty);
			dictionary.Add("(Control.VerticalAlignment)", FrameworkElement.VerticalAlignmentProperty);
			dictionary.Add("(Control.Visibility)", UIElement.VisibilityProperty);
			dictionary.Add("(StackPanel.Orientation)", StackPanel.OrientationProperty);
			ExtendedVisualStateManager.PathToPropertyMap = dictionary;
		}
	}
}
